<%@ page errorPage="Error.jsp" %>
<%@ include file="Header.jsp" %>
<%@ page import="java.util.*" %>


<h2>Manual Daily Project Developer Email</h2>
<form id="AlertEmailEntryForm" action="controller" method="POST">
  <table id="ProjectOwnedTable" border="1">
    <tr>
      <th class="data">Project</th>
      <th class="data">Emails (separate by commas)</th>
      <th class="data">Current Developers recieving emails</th>
      <th class="data">Enabled</th>
    </tr>
    <if test="${empty ProjectsOwned}">
      <c:out value="You have no projects defined"/>
    </if>
    <c:forEach var="project" items="${ProjectsOwned}" varStatus="status">
      <tr>
        <td valign="top">
          <c:out value="${project.name}"/>
        </td>
        <td valign="top">
          <input type="text" name="emails<c:out value="${status.index}"/>" value="" size="50">
        </td>
        <td valign="top">
          <c:choose>
            <c:when test="${empty EmailList[project]}">
              <c:out value="none"/>
            </c:when>
            <c:otherwise>
              <c:forEach var="email" items="${EmailList[project]}">
                <c:out value="${email}"/><br>
              </c:forEach>
            </c:otherwise>
          </c:choose>
        </td>
        <td valign="top">
          <%@ include file="AlertManagerSelector.jsp" %>
          <br>
        </td>
      </tr>
    </c:forEach>
  </table>
<br>
<c:out value="${ValidEmailFeedback}"/>
<c:forEach var="validEmail" items="${ValidEmailList}">
  <c:out value="${validEmail}"/>
</c:forEach>
<br>
<c:out value="${InvalidEmailFeedback}"/>
<c:forEach var="invalidEmail" items="${InvalidEmailList}">
  <c:out value="${invalidEmail}"/>
</c:forEach>
<br>
<c:out value="${AlertEnableFeedback}"/>
<c:forEach var="enableFeedback" items="${AlertEnableList}">
  <c:out value="${enableFeedback}"/>
</c:forEach>
<br><br>
   <input type="hidden" name="Command" value="AlertEmailManagerUpdate">
   <input type="hidden" name="Key" value="<c:out value="${user.userKey}"/>">
   <input type="hidden" name="ProjectName" value="<c:out value="${Project.name}"/>" />
   <input type="submit" name="Submit" value="Update Emails">
</form>
<br>
<form id="AlertEmailManagerForm" action="controller" method="POST">
   <input type="hidden" name="Command" value="AlertEmailManager">
   <input type="hidden" name="Key" value="<c:out value="${user.userKey}"/>">
   <input type=hidden name="ProjectName" value="<c:out value="${Project.name}"/>" />
   <input type="submit" name="Submit" value="Enable Alert">
</form>
<br>